<style>
    #blackList-add {
        padding: 20px 25px 25px 0;
    }
</style>
<div class="layui-fluid" id="blackList-add">
    <form class="layui-form" lay-filter="blackList-add-form">
        <div class="layui-form-item ">
            <div class="layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">姓名：</label>
                    <div class="layui-input-block">
                        <input type="text" name="name" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">证件类型：</label>
                    <div class="layui-input-block">
                        <select name="identityTypeCode" lay-filter="identityTypeCode" lay-verify="required" id="identityTypeCode">
                            <option value="">请选择</option>
                            <option
                                    th:each="item : ${zjlxList}"
                                    th:value="${item.code}" th:text="${item.name}">
                            </option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item ">
            <div class="layui-row">
                <div class="layui-col-md6">
                    <label class="layui-form-label website-form-item-require">证件号：</label>
                    <div class="layui-input-block">
                        <input type="text" id="identityId" name="identity" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-row">
                <div class="layui-col-md12">
                    <label class="layui-form-label website-form-item-require">加入黑名单原因：</label>
                    <div class="layui-input-block">
                        <textarea name="reason" lay-verify="required" placeholder="请输入内容" rows="5" class="layui-textarea"></textarea>
                    </div>
               </div>
            </div>
        </div>
        <div class="layui-form-item website-hide">
            <button class="layui-btn" lay-submit="" lay-filter="blackList-add-form-submit" id="submit"></button>
            <button type="reset" class="layui-btn" id="reset"></button>
        </div>
    </form>
</div>

<script>
    layui.use(['website', 'form', 'validate'], function () {
        var $ = layui.$,
            website = layui.website,
            layer = layui.layer,
            form = layui.form,
            $view = $('#blackList-add'),
            validate = layui.validate;

        form.verify(validate);
        form.render();
        form.on('select(identityTypeCode)', function (data) {
            if ("zjlx_sfz" === data.value) {
                $('#identityId')[0].setAttribute('lay-verify', "required|identityNumber")
            }else {
                $('#identityId')[0].setAttribute('lay-verify', "required")
            }
        });
        form.on('submit(blackList-add-form-submit)', function (data) {
            website.post(ctx + 'blackList', data.field, function () {
                layer.closeAll();
                website.alert.success('新增成功');
                $('#website-blackList').find('#query').click();
            });
            return false;
        });
    });
</script>